package com.boot.imply.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.boot.imply.entity.Wikipedia;
import com.boot.imply.service.WikipediaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping({"test"})
public class WikipediaController {

    @Autowired
    private WikipediaService wikipediaService;

    @GetMapping({"list"})
    public List<Wikipedia> list() {
        return wikipediaService.seletcs();
    }

    @GetMapping({"page"})
    public IPage<Wikipedia> page(@RequestParam(value = "page",defaultValue = "1") Integer page, @RequestParam(value = "size",defaultValue = "10")Integer size) {
        long start = System.currentTimeMillis();
        IPage<Wikipedia> ipage = wikipediaService.page(page,size);
        System.out.println("分页查询耗时 =" + (System.currentTimeMillis() - start) + "毫秒");
        return ipage;
    }
}
